<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <a href="https://bing.com" id="link">link</a>
    <script>
      const link = document.getElementById("link");
      // 将a标签元素的跳转行为看做是click事件的默认行为
      link.onclick = function (e) {
        alert("hello"); //业务代码

        return false;
        // 默认行为，默认代码
      };
    </script>
  </body>
</html>
